using System;
using System.Collections.Generic;
using System.Text;
using System.Data .OleDb;
using System.Data ;
using DTO;

namespace DAO
{
   public class ChucVuDAO
    {
       //ham lay danh sach chuc vu len tu csdl
       public List<ChucVuDTO> laydanhsachchucvu_DAO()
       {
           List<ChucVuDTO> list = new List<ChucVuDTO>();
           string sql = "select * from ChucVu";
           DataTable dt = DataProvider.ExcuteQuery(sql);
           if (dt.Rows.Count > 0)
           {
               for (int i = 0; i < dt.Rows.Count; i++)
               { 
                   DataRow dr = dt.Rows[i];
                   
                   int machucvu = int.Parse(dr["MaChucVu"].ToString());
                   string tenchucvu = dr["TenChucVu"].ToString();
                  
                   ChucVuDTO cv = new ChucVuDTO ();
                  
                   cv.Machucvu = machucvu;
                   cv.Tenchucvu = tenchucvu;
                 
                   list.Add(cv);
               }
           }
           return list;

       }
       public ChucVuDTO laytentheoma_DAO(int machucvu)
       {
           ChucVuDTO cv = new ChucVuDTO();
           string sql = "select * from ChucVu where MaChucVu = " + machucvu;
           DataTable dt = DataProvider.ExcuteQuery(sql);
           DataRow dr = dt.Rows[0];
           string tenchucvu = dr["TenChucVu"].ToString();
           cv.Tenchucvu = tenchucvu;
           return cv;
       }
    }
}
